Error Boundary
React
で
例外処理
的なことをする仕組み
子コンポーネントでのエラーを親でcatchする
https://reactjs.org/docs/error-boundaries.html
static getDerivedStateFromError()
か
componentDidCatch()
を使う(もしくは両方)
この二つはまだ
Hooks
では使えないので、classコンポーネントにすることになる
https://reactjs.org/docs/hooks-faq.html#how-do-lifecycle-methods-correspond-to-hooks